
from lib.api.Teacher import tm
from lib.webui.TeacherOp import top
from hytest import STEP, INFO, CHECK_POINT, GSTORE
from config.cfg import *


class TeacherWeb2:
    name = "老师登录2 - tc005002"

    def teststeps(self):
        STEP(1, "添加老师")

        classid = GSTORE['七一班-id']

        ret = tm.add_teacher(username='sun', realname='孙老师', subjectid=SUBJECT_ID_JUNIOR_MATH,
                             classlist=str(classid), phonenumber="1234567", email="sunan@163.com",
                             idcardnumber="123123")
        retAdd = ret.json()

        CHECK_POINT("添加老师检查", retAdd['retcode'] == 0)

        self.teacherid = retAdd['id']

        STEP(2, "老师登录web界面")

        top.teacherLogin(username='sun', password='888888')
        infos = top.getTeaHomePageInfo()

        INFO(f'老师主页数据: {infos}')

        expected = ['白月学院00002', '孙老师', '初中数学', '0', '0', '0']

        CHECK_POINT('老师首页信息检查', infos == expected)

        STEP(3, "获取班级学生信息")

        info = top.getTeaClassStudent()

        INFO(f'班级学生信息: {info}')

        CHECK_POINT('学生信息检查', info == '中学生')



    def teardown(self):
        tm.delete_teacher(self.teacherid)

